//package com.wdd.myplatform.config.pulsar;
//
//import org.apache.poi.ss.formula.functions.T;
//import org.apache.pulsar.client.api.*;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * @author wdd 2022/7/18
// */
//@Configuration
//public class PulsarConsumerConfig {
//    @Autowired
//    PulsarClient pulsarClient;
//
//    @Value("${consumer.name:consumerName}")
//    String consumerName;
//
//    @Value("${topic.name:airquality}")
//    String topicName;
//
//    @Value("${subscription.name:airqualitysubscription}")
//    String subscriptionName;
//
//    @Autowired
//    private PulsarMsgListener pulsarMsgListener;
//
//    @Bean
//    public Consumer<T> getConsumer() {
//        Consumer pulsarConsumer = null;
//        ConsumerBuilder consumerBuilder =
//                pulsarClient.newConsumer()
//                        .topic(topicName)
//                        .subscriptionName(subscriptionName)
//                        .subscriptionType(SubscriptionType.Shared)
//                        .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
//                        .messageListener(pulsarMsgListener)
//                        .consumerName(consumerName);
//        try {
//            pulsarConsumer = consumerBuilder.subscribe();
//        } catch (PulsarClientException e) {
//            e.printStackTrace();
//        }
//        return pulsarConsumer;
//    }
//}
